import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/views/Home'


Vue.use(VueRouter)

const routes = [{
        path: '/',
        redirect: { name: 'Login' }
    },

    {
        path: '/login',
        name: 'Login',
        component: () =>
            import ( /* webpackChunkName: "login" */ '../views/login.vue')

    },
    {
        path: '/music',
        name: 'Music',
        component: () =>
            import ( /* webpackChunkName: "home" */ '../views/music.vue'),
        children: [{
                path: '/',
                redirect: { name: 'Home' }
            },
            {
                path: '/home',
                name: 'Home',
                component: () =>
                    import ( /* webpackChunkName: "home" */ '../views/Home/index.vue')
            },


            {
                path: '/mounts/:id',
                name: 'Mounts',
                component: () =>
                    import ('../views/Home/mounts.vue')
            },




            {
                path: '/top',
                name: 'Top',
                component: () =>
                    import ( /* webpackChunkName: "top" */ '../views/Top.vue')
            },
            {
                path: '/me',
                name: 'Me',
                component: () =>
                    import ( /* webpackChunkName: "me" */ '../views/Me.vue')
            },
            {
                path: '/search',
                name: 'Search',
                component: () =>
                    import ( /* webpackChunkName: "search" */ '../views/Search.vue')
            }
        ]

    },
    {
        path: '/play/:id',
        name: 'Play',
        component: () =>
            import ('../views/Home/play.vue')
    },
    {
        path: '/plays/:id',
        name: 'Plays',
        component: () =>
            import ('../views/Home/plays.vue')
    },
    {
        path: '/modj/:id',
        name: 'Modj',
        component: () =>
            import ('../components/modj.vue')
    },

]

const router = new VueRouter({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes,

})

// 解决路由重复问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default router